package vn.fsoft.gst.dao;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import vn.fsoft.gst.domain.Sic;

/**
 * 
 * @author TienNM
 *
 */

@Repository
@SuppressWarnings({"unchecked"})
public class SicDAOImpl implements SicDAO {

	@Autowired
	SessionFactory sessionFactory;
	
	@Transactional
	public void addSic(Sic sic) {
		sessionFactory.getCurrentSession().save(sic);
	}
	
	
	public List<Sic> getListSic() {
    	List<Sic> listSic = null;
    	
    	listSic = sessionFactory.getCurrentSession().createQuery("from Sic").list();
    	
    	return listSic;
    	
    }
    
    public Sic getSicByCode(String code) {
    	Sic sic = null;
    	
    	sic = (Sic) sessionFactory.getCurrentSession().get(Sic.class, code);
    	
    	return sic;
    }
    
    public String getTypeOfBussiness(String sicCode){
    	Sic sic = (Sic) sessionFactory.getCurrentSession().get(Sic.class, sicCode);    	
    	return sic.getTypeOfBussiness();
    }

}
